﻿using PetaPoco;
using PmSoft;
using PmSoft.Caching;
using System.ComponentModel;
using static Modules.Audit.SysAuditLogConstants;
using static Modules.System.Flow.FlowConstants;

namespace Modules
{
    /// <summary>
    /// 流程审核记录
    ///</summary>
    [TableName("sys_audit_log")]
    [Description("流程审核记录")]
    [PrimaryKey("id", AutoIncrement = true)]
    [CacheSetting(true, PropertyNamesOfArea = "ObjectId")]
    [Serializable]
    public class SysAuditLog : IEntity
    {
        /// <summary>
        /// 主键
        ///</summary>
        [Column("id")]
        public int Id { get; set; }

        /// <summary>
        /// 流程id
        ///</summary>
        [Column("flow_id")]
        public int FlowId { get; set; }

        /// <summary>
        /// 步骤编码
        ///</summary>
        [Column("flow_engine_code")]
        public FlowEngine FlowEngineCode { get; set; }

        /// <summary>
        /// 顺序
        ///</summary>
        [Column("sort")]
        public int? Sort { get; set; }

        /// <summary>
        /// 主表(业务表)id
        ///</summary>
        [Column("object_id")]
        public int ObjectId { get; set; }

        /// <summary>
        /// 业务表名
        ///</summary>
        [Column("table_name")]
        public string TableName { get; set; }

        /// <summary>
        /// 审核状态  0,待审核  1.已审核
        ///</summary>
        [Column("audit_status")]
        public AuditStatus AuditStatus { get; set; }

        /// <summary>
        /// 审核意见 (1:成功  -1:失败)
        ///</summary>
        [Column("audit_idea")]
        public AuditIdea AuditIdea { get; set; }

        /// <summary>
        /// 意见描述
        ///</summary>
        [Column("audit_idea_content")]
        public string? AuditIdeaContent { get; set; }

        /// <summary>
        /// 创建时间
        ///</summary>
        [Column("create_time")]
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 审核时间
        ///</summary>
        [Column("audit_time")]
        public DateTime? AuditTime { get; set; }

        /// <summary>
        /// 创建人
        ///</summary>
        [Column("create_user_id")]
        public int CreateUserId { get; set; }

        /// <summary>
        /// 审核人
        ///</summary>
        [Column("audit_user_id")]
        public int? AuditUserId { get; set; }

        /// <summary>
        /// 创建人名称
        ///</summary>
        [Column("create_user_name")]
        public string CreateUserName { get; set; }

        /// <summary>
        /// 审核人 名称
        ///</summary>
        [Column("audit_user_name")]
        public string? AuditUserName { get; set; }

        #region IEntity 成员

        [Ignore]
        object IEntity.EntityId { get { return this.Id; } }

        #endregion IEntity 成员
    }
}